#!/bin/bash
# -*-Shell-script-*-
#
# Desktop-cherry, Configure your Fedora in a friendly maner.
#
# Copyright (C) 2007,2008 Globaltek - Solucoes Informaticas, Lda.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Contact the author at: Rui Gouveia <rui.gouveia(_at_)globaltek.pt>
# 

################################
# Target distro

RELEASE='9'
SCRIPT_DISTRO="Fedora $RELEASE"
SCRIPT_VERSION='0.8'

SCRIPT_PATH=`pwd`

#############################################################################
## Prep

# yum debug level.
yum_debug=2

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]; then
    echo "Network offline. Try again..."
    exit 0
fi

# Check if we are root?
if [ "$UID" != 0 ]; then
    echo "You are not root. Please run me as root. Thanks."
    exit 0
fi

# Check if we are running in the proper distro version.
if ! grep -q "Fedora release $RELEASE" /etc/redhat-release; then 
    echo "This script is intended for the Fedora $RELEASE only..."
    exit 0
fi


#############################################################################
## Disable SELINUX

function sys_selinux () {

    echo -e "\n##################################################"
    echo -e "# Disable selinux\n"

    if [ `/usr/sbin/getenforce` != "Disabled" ]; then
        echo "Disabling SELINUX..."
        sed -i.bak \
            -e 's/^SELINUX=.*$/SELINUX=disabled/' \
            /etc/selinux/config

	echo 'SELinux is disabled. A Reboot is necessary for the new'
	echo 'configuration to become active... at your time. No rush.'
    else
        echo 'SELinux already disabled. Skipping.'
    fi
}

#############################################################################
## Configure fsck to run automaticaly on cold shutdown

function sys_autofsck () {

    echo -e "\n##################################################"
    echo -e "# Autofsck\n"

    if [ ! -f /etc/sysconfig/autofsck ]; then
        cat<<EOF> /etc/sysconfig/autofsck
AUTOFSCK_DEF_CHECK=yes
PROMPT=no
EOF
        echo 'AUTO FSCK Enabled.'
    else
        echo 'File /etc/sysconfig/autofsck already exists. No change.'
    fi    
}

#############################################################################
## Configure services.

function sys_services () {

    echo -e "\n##################################################"
    echo -e "# System Services\n"

    chkconfig apmd off
    chkconfig autofs off
    chkconfig avahi-daemon off
    chkconfig dhcdbd off
    chkconfig fedora-live off
    chkconfig hidd off
    chkconfig isdn off
    chkconfig mcstrans off
    chkconfig mdmonitor off
    chkconfig nasd off
    chkconfig netfs off
    chkconfig NetworkManager on
    chkconfig NetworkManagerDispatcher on
    chkconfig nfslock off
    chkconfig network off
    chkconfig pcscd off
    chkconfig portmap off
    chkconfig postfix off
    chkconfig restorecond off
    chkconfig rpcbind off
    chkconfig rpcgssd off
    chkconfig rpcidmapd off
    chkconfig rpcsvcgssd off
    chkconfig sendmail off
    chkconfig setroubleshoot off
    chkconfig sshd on
    chkconfig vncserver off
    chkconfig yum-updateonboot off
    chkconfig yum-updatesd on
}

#############################################################################
# Configure logrotate.conf

function sys_logrotate () {

    echo -e "\n##################################################"
    echo -e "# Syslog rotate\n"

    if [ -f /etc/logrotate.conf.bak ]; then
        echo 'Logrotate already configured. Skipping...'
    else
        sed -i.bak \
            -e 's/^#compress/compress/' \
            /etc/logrotate.conf

        echo 'Logrotate configured.'
    fi
}

#############################################################################
# Configure yum-updatesd.conf

function sys_yum_updatesd () {

    echo -e "\n##################################################"
    echo -e "# yum updates daemon\n"

    if [ -f /etc/yum/yum-updatesd.conf.bak ]; then
	echo 'yum-updatesd.conf already configured. Skipping...'
    else
	if [ ! -f /etc/yum/yum-updatesd.conf ]; then
	    yum -d $yum_debug -y install yum-updatesd
	fi

	echo 'Configure yum-updatesd.conf...'
	
	sed -i.bak \
	    -e 's/^run_interval =.*/run_interval = 43200/' \
	    -e 's/^emit_via =.*/emit_via = syslog/' \
	    -e 's/^do_update =.*/do_update = yes/' \
	    -e 's/^do_download =.*/do_download = yes/' \
	    -e 's/^do_download_deps =.*/do_download_deps = yes/' \
	    /etc/yum/yum-updatesd.conf
    fi
}

#############################################################################
# Miscellaneous configs

function sys_misc () {

    echo -e "\n##################################################"
    echo -e "# System miscellaneous configs\n"

    echo
    echo -n 'Do you want to disable IPV6? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
        if ! grep -q "blacklist ipv6" /etc/modprobe.conf; then
            cat<<EOF>>/etc/modprobe.conf
# disable IPV6
blacklist ipv6
EOF
            sed -i.bak \
                -e 's/^NETWORKING_IPV6=.*/NETWORKING_IPV6=no/' \
                /etc/sysconfig/network
            chkconfig ip6tables off
        fi
    fi

    echo
    echo -n 'Do you want to enable Kernel System Request? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
        sed -i.bak \
            -e 's/kernel.sysrq =.*/kernel.sysrq = 1/' \
            /etc/sysctl.conf
    fi

    echo
    echo -n 'Do you want to enable ssh X11 forward? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
        sed -i.bak \
            -e 's/#.*ForwardX11.*/ForwardX11 yes\nForwardX11Trusted yes/' \
            /etc/ssh/ssh_config
    fi
}

#############################################################################
## Update functions.

function _clean_plugins () {

    echo 'Performing plugins cleanups...'
    RPMS="totem-mozplugin HelixPlayer-plugin totem-xine-mozplugin"

    for rpm in $RPMS; do
	    if rpm --quiet -q $rpm; then
	        echo "Removing package: $rpm ..."
	        rpm -ev $rpm
	    fi
    done
}

function _change_mta () {

    if rpm --quiet -q sendmail; then
	    echo 'Changing MTA: Sendmail -> Postfix...'
	    yum -d $yum_debug -y install postfix
	    rpm -e sendmail
    fi
}

function _change_totem () {

    if rpm --quiet -q totem; then
	    echo 'Replacing totem with totem-xine...'
	    rpm -ev --nodeps totem
	    yum -d $yum_debug -y install totem-xine
    fi
}

function _install () {
    rpms=$1

    install=0
    for rpm in $rpms; do
	if [ "$install" == "0" ]; then
	    echo "Checking $rpm..."
	    if ! rpm --quiet -q $rpm; then
		    install=1
	    fi
	fi
    done

    if [ "$install" == "0" ]; then
	echo 'Listed software already installed'
	echo
    else
	echo "Installing software: $rpms"
	yum -d $yum_debug -y install $rpms
    fi
}

#############################################################################
## Update

function update () {

    echo -e "\n##################################################"
    echo -e "# System Update\n"

    _clean_plugins

    echo 'Checking for yum update...'
    yum -d $yum_debug -y update yum
    
    echo 'Installing yum plugins: fastestmirror...'
    yum -d $yum_debug -y install yum-fastestmirror yum-presto

    echo -n 'Do you want to install packages automatically (yum will not ask for confirmation)? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
	if ! grep -q assumeyes /etc/yum.conf ; then
	    sed -i.bak \
	        -e 's/.*metadata.*/&\nassumeyes=1/' \
		/etc/yum.conf
	fi
    fi

    echo 'Importing rpm gpg keys...'
    rpm --import /etc/pki/rpm-gpg/*

    _change_mta
    
    echo 'Updating the system... this may take a while...'
    yum -d $yum_debug -y update
}

#############################################################################
## Aditional software

function extras () {
 
    echo -e "\n##################################################"
    echo -e "# Additional software\n"

    RPMS="pidgin gftp gwget thunderbird ncftp"
    echo
    echo $RPMS
    echo
    echo -n 'Do you want to install graphical internet software? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
	_install "$RPMS"
    fi

    # Change totem package with the version that suports proprietary codecs.
    _change_totem

    RPMS="amarok-extras-nonfree audacious-plugins-nonfree* ffmpeg gecko-mediaplayer gstreamer-ffmpeg gstreamer-plugins-bad gstreamer-plugins-ugly k3b k3b-extras-nonfree kdemultimedia-extras-nonfree lame libdvdcss libdvdnav libdvdplay libdvbpsi lsdvd mozilla-totem-xine mplayer mplayer-fonts mplayer-gui mplayerplug-in ogmtools rhythmbox xine xine-lib-extras-nonfree xmms-faad2 xmms-mp3 xmms-normalize"

    echo 
    echo $RPMS
    echo
    echo -n 'Do you want to install sound and video software? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
	    _install "$RPMS"
        if [ ! -f /etc/skel/.mplayer/config ]; then
            mkdir /etc/skel/.mplayer
            cat<<EOF>/etc/skel/.mplayer/config
vo=xv
ao=alsa
EOF
        fi
    fi

    RPMS="amule bittorrent bittorrent-gui ktorrent linuxdcpp"

    echo 
    echo $RPMS
    echo
    echo -n 'Do you want to install P2P software? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
	    _install "$RPMS"
    fi

    RPMS="bitstream-vera-fonts fuse fuse-libs ntfs-3g unrar" 

    echo 
    echo $RPMS
    echo
    echo -n 'Do you want to install this other software? [yes]: '
    read answer

    if [ "$answer" == "yes" ] || [ "$answer" == "" ]; then
	    _install "$RPMS"
    fi
}

#############################################################################
# Installing aditional repos

function sys_repos () {

    echo -e "\n##################################################"
    echo -e "# Additional repositories\n"

    # Flash Player
    if [ ! -f /etc/yum.repos.d/adobe-linux-i386.repo ]; then
	echo 'Installing Flash Player repo...'
        rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
	rpm -Uvh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
    else
	echo 'Flash Player repo already installed.'
    fi
    
    # Skype
    if [ ! -f /etc/yum.repos.d/skype.repo ]; then
	echo 'Installing Skype repo'
        rpm --import http://www.skype.com/download/skype/linux/rpm-public-key.asc
	cat <<EOF> /etc/yum.repos.d/skype.repo
[skype]
name=Skype Repository
baseurl=http://download.skype.com/linux/repos/fedora/updates/i586/
gpgkey=http://www.skype.com/download/skype/linux/rpm-public-key.asc
gpgcheck=1
enabled=0
EOF
    else
	echo 'Skype repo already installed.'
    fi

    # Livna
    if [ ! -f /etc/yum.repos.d/livna.repo ]; then
        echo 'Installing livna yum repo...'
        rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-livna
        rpm -Uvh http://rpm.livna.org/livna-release-$RELEASE.rpm
    else
	echo 'Livna repo already installed.'
    fi
    
    # Freshrpms
    if [ ! -f /etc/yum.repos.d/freshrpms.repo ]; then
        echo 'Installing Freshrpms yum repo, and leaving it disabled'
        echo 'To install software, use:  yum --enabledrepo=freshrpms ...'
        rpm --import http://freshrpms.net/RPM-GPG-KEY-freshrpms
        rpm -Uvh http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/$RELEASE/freshrpms-release/freshrpms-release-1.1-1.fc.noarch.rpm

        if ! grep -q enabled /etc/yum.repos.d/freshrpms.repo; then
            echo -e "enabled=0\n" >> /etc/yum.repos.d/freshrpms.repo
        else
            sed -i.bak -e 's/enabled.*/enabled=0/' /etc/yum.repos.d/freshrpms.repo
        fi
    else
	echo 'Freshrpms repo already installed.'
    fi

    # ATrpms
    if [ ! -f /etc/yum.repos.d/atrpms.repo ]; then
        echo 'Installing ATrpms yum repo, and leaving it disabled'
        echo 'To install software, use:  yum --enabledrepo=atrpms ...'
        rpm --import http://atrpms.net/RPM-GPG-KEY.atrpms
        cat<<EOF>/etc/yum.repos.d/atrpms.repo
[atrpms]
name=Fedora $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/f$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=0
EOF
    else
    	echo 'ATrpms repo already installed.'
    fi

    # Google
    if [ ! -f /etc/yum.repos.d/google.repo ]; then
        echo 'Installing Google yum repo, and leaving it disabled'
        echo 'To install software, use:  yum --enabledrepo=google ...'
        rpm --import http://dl.google.com/linux/linux_signing_key.pub
        cat<<EOF>/etc/yum.repos.d/google.repo
[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
gpgkey=http://dl.google.com/linux/linux_signing_key.pub
gpgcheck=1
enabled=0
EOF
    else
    	echo 'Google repo already installed.'
    fi
}

#############################################################################
# Flash Player - http://adobe.com/

function flash_player () {

    echo -e "\n##################################################"
    echo -e "# Flash Player\n"

    if [ ! -f /etc/yum.repos.d/adobe-linux-i386.repo ]; then
	echo 'Repo Adobe repo not installed. Install repos first.'
    else
	if [ ! -f /usr/lib/flash-plugin/libflashplayer.so ]; then
	    echo 'Installing Flash Player...'
	    yum -d $yum_debug -y install flash-plugin
	else
	    echo 'Flash Player already installed. Skipping'
	fi
    fi
}

#############################################################################
# Adobe reader - www.adobe.com

function acrobat_reader () {

    echo -e "\n##################################################"
    echo -e "# Acrobat Reader\n"

    if [ ! -f /usr/bin/acroread ]; then
	    # Install from Adobe site
	    rpm -Uvh http://ardownload.adobe.com/pub/adobe/reader/unix/8.x/8.1.2/enu/AdobeReader_enu-8.1.2-1.i486.rpm

	    echo 'Installing Firefox plugin...'
	    ACROBAT_MOZ_PLUGIN=`rpm -ql AdobeReader_enu | grep 'Browser/intellinux/nppdf.so'`
        if [ ! -f /usr/lib/mozilla/plugins/nppdf.so ]; then
	        ln -s $ACROBAT_MOZ_PLUGIN /usr/lib/mozilla/plugins/
        fi
    else
        echo 'Adobe Acrobat Reader already installed. Skipping...'
    fi
}

#############################################################################
# Skype - www.skype.com

function skype () {

    echo -e "\n##################################################"
    echo -e "# Skype\n"

    if [ ! -f /etc/yum.repos.d/skype.repo ]; then
	echo 'Repo Skype not installed. Install repos first.'
    else
	if [ ! -f /usr/share/applications/skype.desktop ]; then
	    echo 'Installing deps...'
	    yum -d $yum_debug -y install qt4 qt4-x11
            /sbin/ldconfig
	    
	    echo 'Installing Skype...'
	    yum -d $yum_debug -y --enablerepo=skype install skype
	else
	    echo 'Skype already installed. Skipping'
	fi
    fi
}

#############################################################################
# Opera www.opera.com

function opera () {

    echo -e "\n##################################################"
    echo -e "# Opera\n"

    if [ ! -f /usr/bin/opera ]; then
	    echo 'Installing deps...'
	    yum -d $yum_debug -y install compat-libstdc++-33 compat-libstdc++-296
            /sbin/ldconfig

	    FILE=`ls -d1 opera-*.rpm`
    	    if [ "$FILE" == "" ]; then
	        echo 'Downloading Opera RPM...'
	        wget http://www.opera.com/download/get.pl?id=29913&location=71&nothanks=yes&sub=marine
	    else
	        echo "Opera RPM already exists. Using '$FILE'."
	    fi
	
	    rpm -Uvh $FILE
    else
	echo 'Already instaled. Skipping.'
    fi
}

#############################################################################
# Multimedia Codecs - http://www.mplayerhq.hu/MPlayer/releases/codecs/

function win32_codecs () {

    echo -e "\n##################################################"
    echo -e "# Win32 Codecs\n"

    if [ ! -f /usr/bin/wget ]; then
	yum -d $yum_debug -y install wget
    fi

    if [ ! -f /usr/lib/codecs/divx.dll ]; then

	CODECS_FILE='all-20071007.tar.bz2'

	if [ ! -f $CODECS_FILE ]; then
	    wget -c http://www1.mplayerhq.hu/MPlayer/releases/codecs/$CODECS_FILE
	fi

	if [ ! -f $CODECS_FILE ] || [ "$CODECS_FILE" == "" ]; then
	    echo 'You need to download the last version of all-********.tar.bz2 codecs file from'
	    echo 'http://www.mplayerhq.hu/dload.html or http://www.mplayerhq.hu/MPlayer/releases/codecs/'
	    echo 'and save it in this folder.'
	    echo 'Run this script again after you do....'
	else
	    if ! rpm --quiet -q totem-xine mplayer xine; then
		echo 'You need to install multimedia software first'
		echo 'Install aditional software first and say YES to multimedia.'
	    else
		echo 'Installing video and audio codecs for mplayer/xine...'
    
		tar xjf $CODECS_FILE --strip-components 1 -C /usr/lib/codecs/
	    
		echo 'Defining link to other programs...'
		ln -s /usr/lib/codecs /usr/lib/win32
		ln -s /usr/lib/codecs /usr/local/lib/codecs
		ln -s /usr/lib/codecs /usr/local/lib/win32
	    fi
	fi
    else
	echo 'Already instaled...'
    fi
}

############################################################################
# MS Truetype Fonts http://corefonts.sourceforge.net/

function ms_tt_fonts {

    echo -e "\n##################################################"
    echo -e "# MS TrueType Fonts\n"

    if ! rpm --quiet -q rpm-build cabextract chkfontpath; then
        yum -d $yum_debug -y install rpm-build cabextract chkfontpath
    fi

    if [ ! -d /usr/share/fonts/msttcorefonts ]; then

	    MSTTF_FILE='msttcorefonts-2.0-1.spec'

	    if [ ! -f $MSTTF_FILE ]; then
	        wget -c http://corefonts.sourceforge.net/$MSTTF_FILE
 	    fi

	    if [ ! -f $MSTTF_FILE ] || [ "$MSTTF_FILE" == "" ]; then
	        echo 'You need to download the latest version of msttcorefonts'
	        echo 'http://corefonts.sourceforge.net/'
	        echo 'and save it in this folder.'
	        echo 'Run this script again after you do so...'
	    else
            rpmbuild -ba msttcorefonts-2.0-1.spec
            rpm -Uvh --nodeps /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
            ln -s /usr/share/fonts/msttcorefonts /etc/X11/fontpath.d/
        fi
    else
	    echo 'Already instaled...'
    fi
}

############################################################################
# Kompozer http://www.kompozer.net/

function kompozer {

    echo -e "\n##################################################"
    echo -e "# Kompozer html editor\n"

    if [ ! -f /usr/bin/kompozer ]; then
	rpm -Uvh http://kent.dl.sourceforge.net/sourceforge/kompozer/kompozer-0.7.10-i386.rpm
    else
	    echo 'Already instaled...'
    fi
}

############################################################################
# Google Earth http://earth.google.com/download-earth.html

function google_earth {

    echo -e "\n##################################################"
    echo -e "# Google Earth\n"

    if [ ! -f /usr/local/bin/googleearth ]; then

        if [ -z "$DISPLAY" ]; then
            echo "You don't seem to be running an X server (no DISPLAY set)."
            echo "Google Earth and its installer both require X11."
            echo "Aborting..."
            return
        fi

	    GOOGLE_EARTH_FILE='GoogleEarthLinux.bin'

	    if [ ! -f $GOOGLE_EARTH_FILE ]; then
	        wget -c http://dl.google.com/earth/client/current/$GOOGLE_EARTH_FILE
	    fi

	    if [ ! -f $GOOGLE_EARTH_FILE ] || [ "$GOOGLE_EARTH_FILE" == "" ]; then
	        echo 'You need to download the latest version of Google Earth'
	        echo 'http://earth.google.com/download-earth.html'
	        echo 'and save it in this folder.'
	        echo 'Run this script again after you do so...'
	    else
		    sh $GOOGLE_EARTH_FILE
        fi
    else
	    echo 'Already instaled...'
    fi
}

############################################################################
# Google Desktop http://desktop.google.com/en/linux/index.html

function google_desktop {

    echo -e "\n##################################################"
    echo -e "# Google Desktop\n"

    if [ ! -f /etc/yum.repos.d/google.repo ]; then
	    echo 'Google repository not installed. Install repos first.'
        echo 'Aborting...'
        return
    fi

    if ! rpm --quiet -q google-desktop-linux; then
	    yum -d $yum_debug -y --enablerepo=google install google-desktop-linux
    else
	    echo 'Already instaled...'
    fi
}

############################################################################
# Picasa http://picasa.google.com/linux/

function picasa {

    echo -e "\n##################################################"
    echo -e "# Picasa\n"

    if [ ! -f /etc/yum.repos.d/google.repo ]; then
	    echo 'Google repository not installed. Install repos first.'
        echo 'Aborting...'
        return
    fi

    if ! rpm --quiet -q picasa; then
	    yum -d $yum_debug -y --enablerepo=google install picasa
    else
	    echo 'Already instaled...'
    fi
}

############################################################################
## Just run all at once

function all_in_one () {

    update
    sys_repos
    sys_selinux
    sys_autofsck
    sys_services
    sys_logrotate
    sys_yum_updatesd
    sys_misc
    extras
    flash_player
    acrobat_reader
    skype
    opera
    win32_codecs
    ms_tt_fonts
    kompozer
    google_earth
    google_desktop
    picasa
}

#############################################################################
##Just install system options

function system_options () {

    sys_repos
    sys_selinux
    sys_autofsck
    sys_services
    sys_logrotate
    sys_yum_updatesd
    sys_misc
}

#############################################################################
## Main loop

declare -i opc=0

while (($opc != 100)); do

    # Flash Player
    if [ ! -f /etc/yum.repos.d/adobe-linux-i386.repo ]; then
        FLASH_MSG='Not OK. Install aditional repos first'
    else
	    if [ ! -f /usr/lib/flash-plugin/libflashplayer.so ]; then
	        FLASH_MSG='Not installed.'
	    else
	        FLASH_MSG='Already installed.'
	    fi
    fi

    # Skype
    if [ ! -f /etc/yum.repos.d/skype.repo ]; then
	    SKYPE_MSG='Not OK. Install aditional repos first'
    else
	    if [ ! -f /usr/bin/skype ]; then
	        SKYPE_MSG='Not installed.'
	    else
	        SKYPE_MSG='Already installed.'
	    fi
    fi

    # Acrobar Reader
    if [ -f /usr/bin/acroread ]; then
	    ACROBAT_MSG='Already installed.'
    else
	    ACROBAT_MSG='Not installed.'
    fi
    
    # Opera
    if [ -f /usr/bin/opera ]; then
        OPERA_MSG='Already installed.'
    else
        OPERA_MSG='Not installed.'
    fi

    if [ -f /usr/lib/codecs/divx.dll ]; then
        CODECS_MSG='Already installed.'
    else
    	CODECS_MSG='Not installed.'
    fi

    if [ -d /usr/share/fonts/msttcorefonts ]; then
	    MSTTF_MSG='Already installed.'
    else
    	MSTTF_MSG='Not installed.'
    fi

    if [ -f /usr/bin/kompozer ]; then
	KOMPOZER_MSG='Already installed.'
    else
    	KOMPOZER_MSG='Not installed.'
    fi

    if [ -f /usr/local/bin/googleearth ]; then
	    GOOGLE_EARTH_MSG='Already installed.'
    else
    	GOOGLE_EARTH_MSG='Not installed.'
    fi

    if [ ! -f /etc/yum.repos.d/google.repo ]; then
	    GOOGLE_DESKTOP_MSG='Not OK. Install aditional repos first'
    else
        if rpm --quiet -q google-desktop-linux; then
	        GOOGLE_DESKTOP_MSG='Already installed.'
        else
    	    GOOGLE_DESKTOP_MSG='Not installed.'
        fi
    fi

    if [ ! -f /etc/yum.repos.d/google.repo ]; then
	    PICASA_MSG='Not OK. Install aditional repos first'
    else
        if rpm --quiet -q picasa; then
	        PICASA_MSG='Already installed.'
        else
    	    PICASA_MSG='Not installed.'
        fi
    fi

    clear
    echo "VERSION: $SCRIPT_VERSION, DISTRO: $SCRIPT_DISTRO


  # System related configuration. (Select options in numerical order)

  101- Update this host                 (Update your packages 'yum update')
  102- Install additional repos         (Only repos safe to use with the Fedora)
  103- Disable SELINUX                  (Desktops don't really need this)
  104- Enable AUTO FSCK on startup      (Check your disks after a cold reboot)
  105- Reconfigure host services        (Turn off idiotic services that are on by default)
  106- Enable logs compression
  107- Enable automatic updates         (No user intervention in the updates)
  108- Miscellaneous configs            (IPV6, ssh, kernel)
  109- Install additional software      (The good stuff!!! Video, Audio, DVD, etc)

  # Free as in 'Free beer' software!!! (NOT FREE! GRATIS!)

  210- Flash Player                     ($FLASH_MSG)
  211- Acrobat Reader                   ($ACROBAT_MSG)
  212- Skype                            ($SKYPE_MSG)
  213- Opera                            ($OPERA_MSG)
  214- Win32 Video/Audio Codecs         ($CODECS_MSG)
  215- MS TrueType Fonts                ($MSTTF_MSG)
  216- Kompozer WYSIWYG html editor     ($KOMPOZER_MSG)
  217- Google Earth                     ($GOOGLE_EARTH_MSG)
  218- Google Desktop                   ($GOOGLE_DESKTOP_MSG)
  219- Picasa                           ($PICASA_MSG)

  500- Install all. Run all option without user intervention.
  501- Execute system configuration options: 102 to 108.

  100- Exit
"

    echo -n 'Insert option: '
    read opc

    case  "$opc" in

        100) 
            echo 'Exiting...'
            ;;

	    101)
	        update
	        ;;

	    102)
	        sys_repos
	        ;;

        103)
            sys_selinux
            ;;

	    104)
	        sys_autofsck
	        ;;

	    105)
	        sys_services
	        ;;

	    106)
	        sys_logrotate
	        ;;

	    107)
	        sys_yum_updatesd
	        ;;

	    108)
	        sys_misc
	        ;;

	    109)
	        extras
	        ;;

	    210)
	        flash_player
	        ;;
	    
	    211)
	        acrobat_reader
	        ;;

	    212)
	        skype
	        ;;

   	    213)
	        opera
	        ;;

	    214)
	        win32_codecs
	        ;;

	    215)
	        ms_tt_fonts
	        ;;

        216)
	        kompozer
	        ;;

        217)
            google_earth
            ;;

        218)
            google_desktop
            ;;

        219)
            picasa
            ;;

	    500)
	        all_in_one
	        ;;

	    501)
	        system_options
	        ;;
	    
        *)
            echo 'Invalid option'
            read tmp
            ;;
        
    esac 

    if [ "$opc" != 100 ]; then
	echo 'Done! Press Enter to continue.'
	read tmp
    fi

done
